#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "config.h"
#include <QIcon>
#include <QPainter>
#include<map1.h>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    MainScene();
    this->p_game1 = new MainWindow_game1;//实例化塔防游戏窗口
    connect(game1_btn,&QPushButton::clicked,[=](){
        this->hide();
        this->p_game1->show();
//        qDebug()<<"lalala";
    });

    //游戏2
    this->p_game2 = new MainWindow_game2;
    connect(game2_btn,&QPushButton::clicked,[=](){
        this->hide();
        this->p_game2->show();
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::MainScene()
{
    //设置窗口尺寸（固定）
    setFixedSize(GAME_WIDTH,GAME_HEIGHT);
    //标题
    setWindowTitle(GAME_TITLE);
    //窗口图标
    setWindowIcon(QIcon(GAME_Icon));
    //主界面按钮
    game1_btn->setParent(this);
    game1_btn->setGeometry(450,300,80,35);
    game1_btn->show();

    game2_btn->setParent(this);
    game2_btn->setGeometry(450,350,80,35);
    game2_btn->show();

    game_exit_btn->setParent(this);
    game_exit_btn->setGeometry(450,400,80,35);
    game_exit_btn->show();
    connect(game_exit_btn,SIGNAL(clicked(bool)),this,SLOT(game_exit()));

//    qDebug()<<"lalala";

}

void MainWindow::playgame1(){

}


void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawPixmap(m_map1.m_map1_posx,m_map1.m_map1_posy,m_map1.m_map1_1);//  尝试绘制地图场景
}

void MainWindow::game_exit()
{
    QApplication *EXIT;
    EXIT->quit();
}
